<?php $this->_extends('_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>

<div class="notification error png_bg">
  <div>
    <?php if(isset($enterprise_autit_status) && !$enterprise_audit_status): ?>
    <li>当前系统审核处于关闭状态</li>
    <?php endif; ?>
    <?php if($permission_id != 3): ?>
    <li>您有<?php echo $reject_count ?>篇文章被退回 <a href="<?php echo url('article/rejectindex'); ?>">查看</a></li>
    <?php else: ?>
    <li>您有<?php echo $audit_count ?>篇文章待审核 </li>
    <?php endif; ?> 
    </div>
</div>


<!--内容部分-->
<?php if ($permission_id != 3): ?>
<a href="<?php echo url('column/index'); ?>"> 栏目管理 </a> | <a href="<?php echo url('article/add'); ?>"> 文章发布 </a>
<?php endif; ?>
<form action="<?php echo url('article/Remove'); ?>" method="post" name="mainform" enctype="multipart/form-data" >
        <table cellpadding="0" cellspacing="0" width="100%">
                <tbody class="">
                        <tr class="tth">
                                <td width="5%">选择</td>
                                <td width="60%">文章标题</td>
                                <td width="20%">栏目</td>
                                <td width="*">文章点击</td>
                                <td width="*"></td>
                        </tr>
                        <?php foreach ($articles as $article):?>
                                <tr class="tth">
                                        <td  width="5%"><input type="checkbox" name="checkboxname[]" id="checkboxid" value="<?php echo $article->article_id ?>" /></td>
                    <td width="60%"> <a href="<?php echo url('article/PreviewArticle', array('article_id' => $article->article_id)) ; ?>"><?php echo $article->article_name; ?>  </a></td>
                    <td width="20%"><?php echo $columns["$article->column_id"]; ?> </td>
                    <td><?php echo $article->read_count; ?>次  </td>                    
                    <?php if($permission_id != 3) :?>
                        <td><a href="<?php echo url('article/edit', array('article_id' => $article->article_id)) ; ?>">[编辑]</a></td>
                    <?php else: ?>
                        <td><a href="<?php echo url('article/preview', array('article_id' => $article->article_id)) ; ?>">[审核]</a></td>
                    <?php endif; ?>
                                </tr>
                        <?php endforeach; ?>	
                        <tr>
                                <td class="tbutton" colspan="6">
                                        <input type="button" value="全选" class="btn" name="choseall" id="Name" onclick = "SelectAll()">
                                        <input type="submit" onclick = "return(CheckFirst())" value="删除" class="btn" name="submit">
                                </td>
                        </tr>
             <input type="hidden" value="<?php echo ($num + 1); ?>" id="hid"> 
                </tbody>
        </table>
</form>
<?php $this->_control('pagination', 'my-pagination', array('pagination' => $pagination)); ?>

<script type="text/javascript">
function SelectAll() 
{
    var flg=0;
    var checkboxs=document.getElementsByName("checkboxname[]");
    var count=0;
    for (var j=0; j<checkboxs.length; j++)
    {
        var e=checkboxs[j];
        if(e.checked)count++;
    }
    if(count < checkboxs.length)
    {
        for (var i=0;i<checkboxs.length;i++) 
        {
            var e=checkboxs[i];
            e.checked =1;
            flg= true;
        }
    }
    else 
    {
        for (var i=0;i<checkboxs.length;i++) 
        {
            var e=checkboxs[i];
            e.checked =0;
            flg= false;
        }
    }

    if (flg)
    {
        document.mainform.choseall.value = "取消";
    }
    else
    {
        document.mainform.choseall.value = "全选";
    }
}

function CheckFirst()
{
    var count=0;
    var checkboxs=document.getElementsByName("checkboxname[]");
    for (var i=0;i<checkboxs.length;i++)
    {
        var e=checkboxs[i];
        if(e.checked)count++;
    }
    if(count == 0)
    {
        alert('请先选择删除条目'); 
        return false;
    }
    else
    {
        if(!confirm('您确认要删除吗?')) 
            return false;
        else
            return true; 
    }
}
</script>
<?php $this->_endblock(); ?>
